package com.gemantic.result;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.List;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;

/**
 * Created by zwzhou on 2016/12/6.
 */
@ApiModel(value = "分页数据")
public class PageResponse<T> {

    @ApiModelProperty(value = "当前页",example="1")
    private Integer currentPage = 1;

    @ApiModelProperty(value = "页面大小",example="10")
    private Integer pageSize = 10;

    @ApiModelProperty(value = "总记录数",example="200")
    private Long totalCount;

    @ApiModelProperty(value = "总页数",example="20")
    private Integer totalPage;

    @ApiModelProperty(value = "分页数据")
    private List<T> list;

    public Integer getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(Integer currentPage) {
        this.currentPage = currentPage;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Long getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(Long totalCount) {
        this.totalCount = totalCount;
    }
    
    public void setTotalCountInt(Integer totalCount) {
    	if(null != totalCount){
    		this.totalCount = Long.valueOf(totalCount);
    	}
    }

    public Integer getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(Integer totalPage) {
        this.totalPage = totalPage;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

	@Override
	public String toString() {
		return MoreObjects.toStringHelper(this).add("currentPage", currentPage).add("pageSize", pageSize)
				.add("totalCount", totalCount).add("totalPage", totalPage).add("list", list).toString();
	}

	@Override
	public int hashCode() {
		return Objects.hashCode(currentPage, pageSize, totalCount, totalPage, list);
	}

	@Override
	public boolean equals(Object object) {
		if (object instanceof PageResponse) {
			PageResponse that = (PageResponse) object;
			return Objects.equal(this.currentPage, that.currentPage) && Objects.equal(this.pageSize, that.pageSize)
					&& Objects.equal(this.totalCount, that.totalCount) && Objects.equal(this.totalPage, that.totalPage)
					&& Objects.equal(this.list, that.list);
		}
		return false;
	}
    
    
    
}
